package com.shop.web;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.shop.entity.Product;
//Action职责 1. 数据校验 2.业务处理
public class ProductAction2 extends ActionSupport  {

	private Product  product;
	
	public String saveProduct(){
		System.out.println("-----saveProduct----");
		return SUCCESS;
	}
	public String deleteProduct(){
		
		return SUCCESS;
	}
	//校验save方法
	public void validateSaveProduct() {
		System.out.println("====validateSaveProduct====");
		if(product!=null && product.getId() ==0){
			super.addFieldError("id", "请输入商品编号");
		}
		System.out.println("name==="+product.getName()+"===");
		if(product.getName()!=null && product.getName().length() ==0 ){
			super.addFieldError("name", "请输入商品名称");
		}
	}
	//校验delete
	public void validateDeleteProduct(){
		System.out.println("====validateDeleteProduct====");
		if( product !=null && product.getId()<=0 ){
			super.addFieldError("id","删除的商品编号不能为空");
		}
	}
	
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	

	
	
	
}
